package com.cdream.basic.util;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.XmlUtil;
import cn.hutool.json.JSONConfig;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.cdream.basic.java8.model.OrderDO;

import java.math.BigDecimal;
import java.util.Date;
import java.util.Map;

public class XmlUtilExample {
    public static void main(String[] args) {
        JSONConfig jsonConfig = JSONConfig.create();
        jsonConfig.setOrder(true);
        JSONObject jsonObject = JSONUtil.parseObj("{\"Order\":{\"OrderHead\":{\"orderType\":\"I\",\"ebpName\":\"大参林医药集团股份有限公司\",\"buyerRegNo\":\"顾水杰\",\"buyerTelephone\":\"13761229484\",\"appTime\":\"20201224112603\",\"orderNo\":\"122012220000013\",\"consignee\":\"顾水杰\",\"buyerIdType\":\"1\",\"freight\":\"0.0\",\"taxTotal\":\"0.0\",\"discount\":\"0.0\",\"goodsValue\":\"0.01\",\"buyerName\":\"顾水杰\",\"consigneeTelephone\":\"13761229484\",\"appStatus\":\"2\",\"ebcCode\":\"440191050U\",\"buyerIdNumber\":\"320681198906204619\",\"appType\":\"1\",\"acturalPaid\":\"0.01\",\"guid\":\"1717CBF1-A215-4D6E-991C-43FB1CD7853C\",\"ebcName\":\"大参林医药集团股份有限公司\",\"ebpCode\":\"440191050U\",\"currency\":\"142\",\"consigneeAddress\":\"七宝万科\"},\"OrderList\":{\"country\":\"116\",\"totalPrice\":\"0.01\",\"itemNo\":\"10483090\",\"gnum\":\"1\",\"itemName\":\"JMSOLUTION 新款面膜组合装（燕窝 蜗牛 鱼子酱 水母）\",\"unit\":\"035\",\"gmodel\":\"保税\",\"price\":\"0.01\",\"qty\":\"1.0\",\"currency\":\"142\"}},\"BaseTransfer\":{\"copCode\":\"440191050U\",\"copName\":\"大参林医药集团股份有限公司\",\"dxpMode\":\"DXP\",\"dxpId\":\"DXPENT0000461945\"}}",jsonConfig);
        System.out.println(XmlUtil.mapToXmlStr(jsonObject));
        OrderDO orderDO = new OrderDO();
        orderDO.setId(1);
        orderDO.setState("str");
        orderDO.setTotalAccount(BigDecimal.ONE);
        orderDO.setCreateTime(new Date());
        Map<String, Object> map = BeanUtil.beanToMap(orderDO);

        String s = XmlUtil.mapToXmlStr(map);
        System.out.println(s);

    }

}
